#define SCORE "Score: %1"
#include "wingame.h"
#include <QVBoxLayout>
#include <QIcon>
WinGame::WinGame(QWidget *parent) :
    QWidget(parent)
{

}

WinGame::WinGame(int x){
    resize(100,100);
    //设置窗口标题
    setWindowTitle(GAME_TITLE);

    //设置图标资源
    setWindowIcon(QIcon(GAME_ICON));  //加头文件 #include <QIcon>
    Quit = new QPushButton("Quit");
    Again = new QPushButton("Again");
    Score = new QLabel(this);
    Score->setText(QString(SCORE).arg(x));
    Win = new QLabel(this);
    Win->setText("Victory!!!");
    Again->setFont(QFont("Algerian",18));
    Again->setStyleSheet("QPushButton{background: transparent; color:white; }"
                                "QPushButton:hover{color:red;}");
    Quit->setFont(QFont("Algerian",18));
    Quit->setStyleSheet("QPushButton{background: transparent; color:white; }"
                                "QPushButton:hover{color:red;}");
    Score->setFont(QFont("Algerian",18));
    Score->setStyleSheet("QLabel{background: transparent; color:white; }"
                                );
    Win->setFont(QFont("Algerian",18));
    Win->setStyleSheet("QLabel{background: transparent; color:white; }"
                                );

    QVBoxLayout *lay = new QVBoxLayout;
    lay->addWidget(Win);
    lay->addWidget(Score);
    lay->addWidget(Quit);
    lay->addWidget(Again);

    setLayout(lay);

    setAutoFillBackground(true);
    QPalette pal;
    QPixmap pixmap("://res/Splash.png");
    pal.setBrush(QPalette::Background, QBrush(pixmap));;
    setPalette(pal);

    connect(Quit,&QPushButton::clicked,this,&WinGame::QuitClicked);
    connect(Again,&QPushButton::clicked,this,&WinGame::AgainClicked);
}

WinGame::~WinGame()
{

}

void WinGame::QuitClicked(){
    this->close();
}
void WinGame::AgainClicked(){
    Mainscene *scene = new Mainscene;
    scene->show();
    this->close();
}


